package com.toppitch.site.data;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.toppitch.site.db.IGetFromResultSet;

public class Comment extends BaseData implements IGetFromResultSet {
	private String commentId;
	private String pitchId;
	private String authorEmail;
	private long postTime;
	private String authorHF;
	private String authorPhotoId;
	private String authorName;
	//not store in db
	private String commentText;
	private boolean authorAvailable;

	public void getFromResultSet(ResultSet rs) throws SQLException {
		commentId = rs.getString("commentId");
		pitchId = rs.getString("pitchId");
		authorEmail = rs.getString("authorEmail");
		postTime = rs.getLong("postTime");
		authorHF = rs.getString("authorHF");
		authorPhotoId = rs.getString("authorPhotoId");
		authorName = rs.getString("authorName");
	}

	public String toInsertString() {
		return toInsertString("comment", commentId, pitchId, authorEmail, postTime, authorHF, authorPhotoId, authorName);
	}

	public String getCommentId() {
		return commentId;
	}

	public void setCommentId(String commentId) {
		this.commentId = commentId;
	}

	public String getPitchId() {
		return pitchId;
	}

	public void setPitchId(String pitchId) {
		this.pitchId = pitchId;
	}

	public String getAuthorEmail() {
		return authorEmail;
	}

	public void setAuthorEmail(String authorEmail) {
		this.authorEmail = authorEmail;
	}

	public long getPostTime() {
		return postTime;
	}

	public void setPostTime(long commitTime) {
		this.postTime = commitTime;
	}

	public String getAuthorHF() {
		return authorHF;
	}

	public void setAuthorHF(String authorHF) {
		this.authorHF = authorHF;
	}

	public String getAuthorPhotoId() {
		return authorPhotoId;
	}

	public void setAuthorPhotoId(String authorPhotoId) {
		this.authorPhotoId = authorPhotoId;
	}

	public String getAuthorName() {
		return authorName;
	}

	public void setAuthorName(String authorName) {
		this.authorName = authorName;
	}

	public String getPostTimeString() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		return sdf.format(new Date(postTime));
	}

	public boolean isStudentAuthor() {
		return "false".equalsIgnoreCase(authorHF);
	}

	public String getCommentText() {
		return commentText;
	}

	public void setCommentText(String commentText) {
		this.commentText = commentText;
	}

	public boolean isAuthorAvailable() {
		return authorAvailable;
	}

	public void setAuthorAvailable(boolean authorAvailable) {
		this.authorAvailable = authorAvailable;
	}
}
